(ns pe.p22
  (:use pe.files)
  (:use pe.seq))

(def base 64) ; base for letter-numeric conversion

(defn numvalue [char]
  (- (int char) base))

(defn alpha-value [word]
  (reduce + (map numvalue word)))

(defn to-score [ab]
  (let [[idx name] ab]
    (* idx (alpha-value name))))

(defn load-names [fname]
  (indexed (map #(.toUpperCase %) (sort (remove-quotes (read-csv "names.txt"))))))

(println (reduce + (map to-score (load-names "names.txt"))))
